define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'patrol/child/index' + location.search,
                    // add_url: 'patrol/child/add',
                    // edit_url: 'patrol/child/edit',
                    // del_url: 'patrol/child/del',
                    multi_url: 'patrol/child/multi',
                    import_url: 'patrol/child/import',
                    table: 'patrol_child',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'patrol_name', title: __('Patrol_id')},
                        {field: 'patrol_inspection_name', title: __('Patrol_inspection_id')},
                        {field: 'shop_name', title: __('Shop_id')},
                        // {field: 'supervisions_status', title: __('Supervisions_status'), searchList: {"1":__('Supervisions_status 1'),"2":__('Supervisions_status 2')}, formatter: Table.api.formatter.status},
                        {field: 'user_staff_name', title: __('User_staff_id')},
                        {field: 'status', title: __('是否完成巡查'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        {field: 'startime', title: __('Startime'), operate: 'LIKE'},
                        {field: 'endtime', title: __('Endtime'), operate: 'LIKE'},
                        // {field: 'sort', title: __('Sort'), operate: 'LIKE'},
                        {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
                        // {field: 'mome', title: __('Mome'), operate: 'LIKE'},
                        {field: 'cases_type_id', title: __('Cases_type_id')},
                        {field: 'money', title: __('Money'), operate: 'LIKE'},
                        {field: 'endstatus', title: __('Endstatus'), searchList: {"1":__('Endstatus 1'),"2":__('Endstatus 2'),"3":__('Endstatus 3')}, formatter: Table.api.formatter.status},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
